<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %>

<div class="modal-dialog ms-modal-dialog">
  <div class="modal-content">

    <div class="modal-header">
      <button type="button" class="close" data-dismiss="modal"><span aria-hidden="true">&times;</span><span class="sr-only">Close</span></button>
      <h4 class="modal-title">修改公司业务信息</h4>
    </div>
      
    <form method="POST" action="${ctx.host}/suppliers/${supplier.id}/supplier-business" class="form-horizontal ms-form modal-search-form" role="form" data-validate="true">
    
      <input type="hidden" name="_method" value="PATCH" />
      <input type="hidden" name="supplierId" value="${supplier.id}" />
      
      <div class="modal-body">
        <div class="form-horizontal ms-form form-personal-info">
    
          <div class="form-group  ms-form-group">
            <label class="control-label col-xs-4"><span class="color-red">*</span>业务类型：</label>
            <div class="col-xs-7 pull-left">
              <select name="businessTypes" data-validate="required" multiple class="select2 multiple form-control">
                <option></option>
                <c:forEach var="businessType" items="${enums['SupplierBusinessType']}">
                  <c:if test="${businessType.type eq supplier.type.alias}">
                    <option value="${businessType.code}" ${supplier.businessType.contains(businessType.code) ? 'selected' : ''}>${businessType.description}</option>
                  </c:if>
                </c:forEach>
              </select>
            </div>
          </div>
          
          <div class="form-group  ms-form-group">  
            <label class="control-label col-xs-4"><span class="color-red">*</span>业务性质：</label>
            <div class="col-xs-7 pull-left">
              <select name="businessNature" data-validate="required" class="select2 form-control">
                <option></option>
                <c:forEach var="businessNature" items="${enums['SupplierBusinessNature']}">
                  <option value="${businessNature}" ${businessNature eq supplier.businessNature ? 'selected' : ''}>${businessNature.description}</option>
                </c:forEach>
              </select>
            </div>
          </div>

          <c:if test="${supplier.type.commonStorage}">
            <div class="form-group  ms-form-group">
              <label class="control-label col-xs-4"><span class="color-red">*</span>供方审核状态：</label>
              <div class="col-xs-7 pull-left">
                <select name="status" data-validate="required" class="select2 form-control">
                  <option></option>
                  <c:forEach var="sas" items="${persist.commonStorageSupplierAuditStatusEnums}">
                    <option value="${sas}" ${sas eq supplier.status ? 'selected' : ''}>${sas.description}</option>
                  </c:forEach>
                </select>
              </div>
            </div>
          </c:if>
            
        </div>
      </div>
      
      <div class="modal-footer ms-modal-footer">
        <button type="submit" class="btn ms-btn btn-primary">确定</button>
        <button type="button" class="btn ms-btn ms-btn-gary" data-dismiss="modal">取消</button>
      </div>
      
    </form>
      
  </div>
</div>

<script type="text/javascript">
    $(document).ready(function () {

        $('select[name="businessTypes"]').select2({
          theme: "classic",
          placeholder: '请选择',
          minimumResultsForSearch: -1,
          allowClear: true
        });

        $('select[name="businessNature"]').select2({
          theme: "classic",
          placeholder: '请选择',
          minimumResultsForSearch: -1,
          allowClear: true
        });

      $('select[name="status"]').select2({
        theme: "classic",
        placeholder: '请选择',
        minimumResultsForSearch: -1,
        allowClear: true
      });

    })
</script>